package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.LikedRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author 蒼飞
 * @since 2023-09-12
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/liked-record")
public class LikedRecordController {
    private final LikedRecordService likedRecordService;

    @PostMapping
    @ApiOperation("点赞或取消点赞")
    public void addLikeRecord(@RequestBody @Valid LikeRecordFormDTO recordDTO) {
        likedRecordService.addLikeRecord(recordDTO);
    }

    /**
     * 对外暴露的feign接口
     * @param bizIds
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("批量查询点赞状态")
    public List<Long> isBizLiked(@RequestParam("bizIds") List<Long> bizIds){
        return likedRecordService.isBizLiked(bizIds);
    }

    @GetMapping("/getOne")
    @ApiOperation("根据业务id查询点赞状态")
    public Long isBizLikedOne(@RequestParam("bizIds") Long id){
        return likedRecordService.isBizLikedOne(id);
    }

}
